<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1,minimum-scale=1,user-scalable=no" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <link rel="stylesheet" type="text/css" href="/public/static/wx/css/base.css" />
    <link rel="stylesheet" type="text/css" href="/public/static/wx/plug-in/layui/css/layui.css" />
    <link rel="stylesheet" type="text/css" href="/public/static/wx/plug-in/mobileSelect.js-master/css/mobileSelect.css" />
    <link rel="stylesheet" type="text/css" href="/public/static/wx/css/creat-order.css" />
    <script src="/public/static/wx/js/flex.js" type="text/javascript" charset="utf-8"></script>
    <title>添加工程师</title>
</head>

<body>

<div class="index">
    <ul class="list">
        <li class="clearfix">

            <p>职位</p>
            <a href="#" id="position" d-name='area'><input type="text" placeholder="请选择职位" j-name="jobs_id" jid="{$info.jobs_id}" /></a>
            <i class="layui-icon layui-icon-triangle-d"></i>
        </li>

        <li class="clearfix">

            <p>登录名称</p>
            <input type="text" placeholder="请输入登录名称" j-name="username" value="{$info.username}" />
        </li>

        <li class="clearfix area">
            <p>密码</p>
            <input type="text" placeholder="请输入密码" j-name="pwd" />
        </li>

        <li class="clearfix">

            <p>头像</p>
            <button type="button" class="layui-btn" id="test1" style="margin-top: 0.2rem;margin-left: 0.5rem;background-color: #06b8a7;">
                +点击上传
            </button>
            <img src="{$info.avatar}" alt="" id="upfile" style="height: 50px;">
        </li>

        <li class="clearfix">

            <p>姓名</p>
            <input type="text" placeholder="请输入姓名" j-name="name" value="{$info.name}" />
        </li>
        <li class="clearfix">

            <p>联系电话</p>
            <input type="text" placeholder="请输入电话号码" j-name="tel" value="{$info.tel}" />
        </li>
        <li class="clearfix">

            <p>邮箱账号</p>
            <input type="text" placeholder="请输入用户邮箱" j-name="email" value="{$info.email}" />
        </li>
        <li class="clearfix">

            <p>简介：</p>
            <textarea j-name="good_at" placeholder="简介">{$info.good_at}</textarea>
        </li>
    </ul>

    <div class="btn" id="sub">
        提交
    </div>

</div>
<script src="/public/static/wx/js/jquery-3.3.1.min.js" type="text/javascript" charset="utf-8"></script>
<script src="/public/static/wx/plug-in/mobileSelect.js-master/js/mobileSelect.js" type="text/javascript" charset="utf-8"></script>
<script src="/public/static/wx/plug-in/layui/layui.all.js" type="text/javascript" charset="utf-8"></script>

<script type="text/javascript">
    //			var layer = layui.layer;

    layui.use('upload', function() {
        var upload = layui.upload;


        var subs = {};

        //执行实例
        var uploadInst = upload.render({
            elem: '#test1' //绑定元素
            ,
            url: '{:url("file")}' //上传接口
            ,
            done: function(res) {
                //上传完毕回调
                if(res.code == 1){
                    subs.avatar = res.url;
                    $('#upfile').attr('src',res.url);
                }
                else{
                    layer.msg(res.info);
                }

            },
            error: function() {
                //请求异常回调
            }
        });


        $('#sub').click(function () {

            $('[j-name]').each(function (k,v) {
                subs[$(this).attr('j-name')] = $(this).val();
            });

            subs.jobs_id = $('[j-name=jobs_id]').attr('jid');

            if('{$of}' == '1'){
                subs.admin_id = '{$info.admin_id}';
            }

            if(!subs.jobs_id||subs.jobs_id.length<=0){
                layer.msg('请选择职位',{icon:5});
                return;
            }
            if(subs.username.length<=0){
                layer.msg('请输入登录名称',{icon:5});
                return;
            }

            if('{$of}' == '0')
            if(subs.pwd.length<=0){
                layer.msg('请输入密码',{icon:5});
                return;
            }

            if(subs.name.length<=0){
                layer.msg('请输入姓名',{icon:5});
                return;
            }
            if(!(/^(13[0-9]|14[579]|15[0-3,5-9]|16[6]|17[0135678]|18[0-9]|19[89])\d{8}$/.test(subs.tel))){
                layer.msg('请输入合法手机号码',{icon:5});
                return;
            }
            if(subs.good_at.length<=0){
                layer.msg('请输入简介',{icon:5});
                return;
            }

            $.post('',subs,function (res) {
                if(res.code == 1){
                    layer.msg(res.msg,{icon:6,shade:0.1},function () {
                        location.href = '{:url("enginUI")}';
                    });
                }else{
                    layer.msg(res.msg,{icon:5});
                }
            })
            
        });

    });


    //阻止手机软键盘弹出
    $(".list li a input").focus(function() {
        document.activeElement.blur();
    });

    var job = {$data|raw};


    var mobileSelect1 = new MobileSelect({
        trigger: '#position',
        title: '职位',
        wheels: [{
            data: job
        }],
        position: [0],
        callback:function (index,dataArr) {
            $('input[j-name=jobs_id]').attr('jid',dataArr[0].id);
        }
    });


    if('{$info.jobs_id}' != ''){
        $.each(job,function (k,v) {
            if('{$info.jobs_id}'==v['id']+''){
                $('input[j-name=jobs_id]').val(v.value);
            }
        });
    }

</script>
</body>

</html>